package com.example.music.controller;

import com.example.commonutils.R;
import com.example.music.model.request.CommentRequest;
import com.example.music.model.request.UserSupportRequest;
import com.example.music.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName AdminController
 * @Author: wx
 * @Create: 2022-10-04  17:12
 * @Description TODO
 * @Version: 1.0
 **/
@Api(description="评论操作")
@RestController
@CrossOrigin //解决跨域问题
public class CommentController {
    @Autowired
    private CommentService commentService;


    /**
     * 提交评论
     * @param addCommentRequest
     * @return
     */
    @ApiOperation("提交评论")
    @PostMapping("/comment/add")
    public R addComment(@RequestBody CommentRequest addCommentRequest) {
        return commentService.addComment(addCommentRequest);
    }
    /**
     * 点赞
     */
    @ApiOperation("点赞")
    @PostMapping("/comment/like1")
    public R commentOfLike(@RequestBody CommentRequest upCommentRequest) {
        return commentService.updateCommentMsg(upCommentRequest);
    }
    // 删除评论
    @ApiOperation("删除评论")
    @GetMapping("/comment/delete")
    public R deleteComment(@RequestParam Integer id) {
        return commentService.deleteComment(id);
    }

    // 获得指定歌曲 ID 的评论列表
    @ApiOperation("获得指定歌曲 ID 的评论列表")
    @GetMapping("/comment/song/detail")
    public R commentOfSongId(@RequestParam Integer songId,@RequestParam(required = false) Integer userId) {
        return commentService.commentOfSongId(songId,userId);
    }

    // 获得指定歌单 ID 的评论列表
    @ApiOperation("获得指定歌单 ID 的评论列表")
    @GetMapping("/comment/songList/detail")
    public R commentOfSongListId(@RequestParam Integer songListId,@RequestParam(required = false) Integer userId) {
        return commentService.commentOfSongListId(songListId,userId);
    }
    // 点赞
    @ApiOperation("评论点赞")
    @PostMapping("/comment/like")
    public R commentOfLike(@RequestBody UserSupportRequest userLike) {
        return commentService.commentLike(userLike);
    }



}
